package com.sc;

import org.junit.Test;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Shen Chao on 2018-06-12-012.
 */
public class MsecToDate {
    @Test
    public void mescToDateDemo() {
        long time = 1489330902308l;
        Date date = new Date();
        System.out.println(System.currentTimeMillis());
        System.out.println(date);
        Date date1 = new Date(time);
        System.out.println(date1);
    }

    @Test
    public void toDate(){
        Date date = new Date();
        DateFormat dateFormat = DateFormat.getDateInstance();
        System.out.println(dateFormat.format(date));
        dateFormat = DateFormat.getDateTimeInstance();
        System.out.println(dateFormat.format(date));
        dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(dateFormat.format(date));
        dateFormat = DateFormat.getInstance();
        System.out.println(dateFormat.format(date));
    }
}
